//
//  XMWithdrawDetailCell.m
//  XMJJ_zml
//
//  Created by apple on 2025/5/16.
//

#import "XMWithdrawDetailCell.h"

@interface XMWithdrawDetailCell ()

@property (nonatomic, strong) UILabel *bankNameLabel;
@property (nonatomic, strong) UIImageView *bankIcon;
@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) UILabel *moneyNumLabel;
@property (nonatomic, strong) UILabel *stateLabel;

@end

@implementation XMWithdrawDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style
              reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    self.contentView.backgroundColor = kColorHEX(0xF7F7F7);
    
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, KScaleWidth(5.0), kScreenWidth, KScaleWidth(120.0))];
    contentView.backgroundColor = kColorHEX(0xffffff);
    [contentView setCornerRadius:KScaleWidth(14.0)];
    [self addSubview:contentView];
    [contentView addSubview:self.bankNameLabel];
    [contentView addSubview:self.bankIcon];
    [contentView addSubview:self.dateLabel];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(KScaleWidth(10.0), KScaleWidth(42.0), kScreenWidth - KScaleWidth(10.0)*2, 1)];
    lineView.backgroundColor = kColorHEX(0xDFDFDF);
    
    [contentView addSubview:lineView];
    [contentView addSubview:self.moneyNumLabel];
    [contentView addSubview:self.stateLabel];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScaleWidth(10.0), contentView.height - KScaleWidth(10.0) - KScaleWidth(31.0), contentView.width - KScaleWidth(10.0), KScaleWidth(31.0)) font:KFontSize(15.0) textColor:kColorHEX(0x818181)];
    titleLabel.text = @"提现金额（元）";
    [contentView addSubview:titleLabel];
}

- (void)setContentWithRecordModel:(XMWithdrawModel *)withdrawModel {
//    _bankIcon.image = [UIImage imageWithColor:kColorHEX(0x00ffff)];
    NSString *imgStr = @[@"mine_withdraw_wechat_icon", @"mine_withdraw_alipay_icon"][[withdrawModel.payType integerValue] - 1];
    _bankIcon.image = ImageNamed(imgStr);
    _bankNameLabel.text = @[@"微信", @"支付宝"][[withdrawModel.payType integerValue] - 1];//@"中国工商银行"; // 1微信 2支付宝
    _dateLabel.text = [[NSDate dateWithTimeIntervalSince1970:[withdrawModel.time integerValue]/1000] dateStringWithFormat:@"yyyy-MM-dd HH:mm:ss"];//@"2014-12-12 11:25:11";
    _moneyNumLabel.text = [NSString stringWithFormat:@"+%@", withdrawModel.money];//@"+88";
//    _stateLabel.text = @"提现成功";
    _stateLabel.text = @[@"提交提现", @"审核通过", @"审核不通过", @"提现成功"][[withdrawModel.status integerValue]/10];
}

#pragma mark - Init
- (UILabel *)bankNameLabel {
    if (!_bankNameLabel) {
        _bankNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScaleWidth(35.0), 0, kScreenWidth - KScaleWidth(35.0) - KScaleWidth(140.0), KScaleWidth(41.0)) font:KFontSize(15.0) textColor:kColorHEX(0x000000)];
    }
    return _bankNameLabel;
}

- (UIImageView *)bankIcon {
    if (!_bankIcon) {
        _bankIcon = [[UIImageView alloc] initWithFrame:CGRectMake(KScaleWidth(10.0), 0, KScaleWidth(19.0), KScaleWidth(41.0))];
        _bankIcon.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _bankIcon;
}

- (UILabel *)dateLabel {
    if (!_dateLabel) {
        _dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth/2, 0, kScreenWidth/2 - KScaleWidth(10.0), KScaleWidth(41.0)) font:KFontSize(13.0) textColor:kColorHEX(0x808080) textAlignment: NSTextAlignmentRight];
    }
    return _dateLabel;
}

- (UILabel *)moneyNumLabel {
    if (!_moneyNumLabel) {
        _moneyNumLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScaleWidth(10.0), KScaleWidth(50.0), kScreenWidth - KScaleWidth(10.0) - KScaleWidth(70.0), KScaleWidth(30.0)) font:KBoldFontSize(19.0) textColor:kColorHEX(0x333333)];
    }
    return _moneyNumLabel;
}

- (UILabel *)stateLabel {
    if (!_stateLabel) {
        _stateLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - KScaleWidth(5.0) - KScaleWidth(70.0), self.moneyNumLabel.y, KScaleWidth(70.0), _moneyNumLabel.height) font:KFontSize(15.0) textColor:kColorHEX(0x3B5998) textAlignment:NSTextAlignmentCenter];
    }
    return _stateLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
